package com.bqjr.xms.controller;

import com.bqjr.xms.modle.ConsumerTemplateUser;
import com.bqjr.xms.service.ConsumerTemplateUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: ConsumerTemplateUserController.
 * @RestController 相当于 @ResponseBody ＋ @Controller合在一起的作用：表示Controller中的方法无法返回jsp页
 *
 * 这边的@RefreshScope注解不能少，否则即使调用/refresh，配置也不会刷新
 *
 * Created by XHZ on 2017/8/7.
 */
@RestController
@RequestMapping("/consumerTemplate")
@RefreshScope
public class ConsumerTemplateUserController {
    @Value("${profile}")
    private String profile;

    @Autowired
    private ConsumerTemplateUserService userConsumerService;

    @GetMapping("/hello")
    public String hello() {
        return this.profile;
    }

    @GetMapping("/{id}")
    public ConsumerTemplateUser findById(@PathVariable Long id) {
        return this.userConsumerService.findById(id);
    }

}
